package com.homedo.odin.solution.controller.pc;

import com.homedo.core.common.base.controller.BaseController;
import com.homedo.core.common.base.dto.Meta;
import com.homedo.core.common.base.dto.ResultData;
import com.homedo.odin.solution.contract.pc.GetBountyReplyListReq;
import com.homedo.odin.solution.contract.pc.GetBountyReplyListResp;
import com.homedo.odin.solution.contract.pc.GetMyBountyReplyListReq;
import com.homedo.odin.solution.contract.pc.GetMyBountyReplyListResp;
import com.homedo.odin.solution.contract.pc.InsertBountyReplyReq;
import com.homedo.odin.solution.contract.pc.InsertBountyReplyResp;
import com.homedo.odin.solution.service.bizservice.personal.BountyReplyBizService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: donglibing
 * @date: 2018/3/6 14:39
 * @Description:
 */
@Api(description = "悬赏回复", tags = {"Bounty"}, produces = MediaType.APPLICATION_JSON_VALUE)
@RestController
@RequestMapping("/personal")
public class BountyReplyController extends BaseController<BountyReplyBizService> {


    @ApiOperation(value = "获取悬赏回复列表", notes = "获取悬赏回复列表", response = GetBountyReplyListResp.class, httpMethod = "GET")
    @GetMapping("/bountyreply/list")
    public ResultData list(@ModelAttribute("request") GetBountyReplyListReq request) {
        GetBountyReplyListResp resp = baseService
                .getBountyReplyList(request.getPageNum(), request.getPageSize(), request.getBountyId());
        GetBountyReplyListResp Object = resp;
        return ResultData.newInstance(Meta.CODE_200, Object);
    }

    @ApiOperation(value = "获取我的悬赏回复列表", notes = "获取我的悬赏回复列表", response = GetMyBountyReplyListResp.class, httpMethod = "GET")
    @GetMapping("/bounty/myreplylist")
    public ResultData myReplyList(@ModelAttribute("req") GetMyBountyReplyListReq req) {
        GetMyBountyReplyListResp resp = baseService.getMyBountyReplyList(req);
        GetMyBountyReplyListResp Object = resp;
        return ResultData.newInstance(Meta.CODE_200, Object);
    }

    @ApiOperation(value = "插入悬赏回复", notes = "插入悬赏回复", response = InsertBountyReplyResp.class, httpMethod = "POST")
    @PostMapping("/bountyreply/insert")
    public ResultData insert(@RequestBody InsertBountyReplyReq req) {
        baseService.insert(req);
        return ResultData.newInstance(Meta.CODE_200, "悬赏回复成功");
    }


}
